package com.black.cat.jvm.rtda;

import com.black.cat.jvm.rtda.heap.methodarea.JMethod;

/**
 * @Author blackcat
 * @create 2021/8/12 15:29
 * @version: 1.0
 * @description:栈帧
 */
public class Frame {

    //stack is implemented as linked list
    Frame lower;

    //局部变量表
    private LocalVars localVars;

    //操作数栈
    private OperandStack operandStack;

    private JThread thread;

    private int nextPC;

    private JMethod method;

    public Frame(JThread thread,JMethod method) {
        this.thread = thread;
        this.method = method;
        this.localVars = new LocalVars(method.maxLocals);
        this.operandStack = new OperandStack(method.maxStack);
    }

    public LocalVars localVars(){
        return localVars;
    }

    public OperandStack operandStack(){
        return operandStack;
    }

    public JThread thread() {
        return this.thread;
    }

    public int nextPC() {
        return this.nextPC;
    }

    public void setNextPC(int nextPC) {
        this.nextPC = nextPC;
    }

    public JMethod method(){
        return this.method;
    }
}
